package com.mars.deepseek.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import okhttp3.OkHttpClient;

import java.util.concurrent.TimeUnit;

/**
 * DeepSeek API配置类
 */
@Configuration
public class DeepSeekConfig {
    
    @Bean
    public OkHttpClient okHttpClient(DeepSeekProperties properties) {
        return new OkHttpClient.Builder()
                .connectTimeout(properties.getConnectTimeout(), TimeUnit.SECONDS)
                .readTimeout(properties.getReadTimeout(), TimeUnit.SECONDS)
                .writeTimeout(properties.getWriteTimeout(), TimeUnit.SECONDS)
                .build();
    }
    
    @Data
    @Component
    @ConfigurationProperties(prefix = "deepseek.api")
    public static class DeepSeekProperties {
        /**
         * DeepSeek API基础URL
         */
        private String baseUrl;
        
        /**
         * DeepSeek API密钥
         */
        private String apiKey;
        
        /**
         * 默认使用的模型名称
         */
        private String model;
        
        /**
         * 请求超时时间(秒)
         */
        private int timeout = 60;
        
        /**
         * 连接超时时间(秒)
         */
        private int connectTimeout = 10;
        
        /**
         * 读取超时时间(秒)
         */
        private int readTimeout = 60;
        
        /**
         * 写入超时时间(秒)
         */
        private int writeTimeout = 10;
    }
} 